package com.yuanfeng.business.controller;

import com.yuanfeng.business.dto.*;
import com.yuanfeng.business.entity.ShopBaseEntity;
import com.yuanfeng.commoms.dto.goods.ShopListQueryDTO;
import com.yuanfeng.commoms.dto.shop.ArticleShopDTO;
import com.yuanfeng.commoms.dto.shop.ShopTreasureGradeUpdateDTO;
import com.yuanfeng.commoms.dto.shop.WebShopListQueryDTO;
import com.yuanfeng.commoms.dto.shop.WebShopListQueryEsDTO;
import com.yuanfeng.commoms.dto.userms.UserTokenBeanDTO;
import com.yuanfeng.commoms.util.ResponseResult;
import com.yuanfeng.commoms.vo.shop.GdsShopDetailResultVO;
import com.yuanfeng.commoms.vo.shop.InvoiceSwitchEntityVO;
import com.yuanfeng.commoms.vo.shop.ShopUserMessageResultVO;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.text.ParseException;
import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/shopBase/info")
public class ShopBaseController extends BaseController {


    /**
     * es 查询店铺数据
     * @return
     */
    @GetMapping("/selectAllShop")
    public List<ArticleShopDTO> selectAllShop() {
        return shopBaseService.selectAllShop();
    }

    /**
     * 根据店铺id查询店铺信息
     * @param shopId
     * @return
     */
    @GetMapping("/selectByShopId")
    public WebShopListQueryEsDTO selectByShopId2(@RequestParam("shopId") Integer shopId) {
        return shopBaseService.selectByShopId2(shopId);
    }
    /**
     * 移动端根据店铺id查询店铺信息
     * @param shopId
     * @return
     */
    @GetMapping("/selectByH5ShopId")
    public ShopListQueryDTO selectByH5ShopId(@RequestParam("shopId") Integer shopId) {
        return shopBaseService.selectByH5ShopId(shopId);
    }

    /**
     * 判断用户的身份 商家 供应商 门店 普通用户
     */
    @PostMapping("/checkTheStatus")
    public ResponseResult checkTheStatus(@RequestBody UserTokenBeanDTO userTokenBeanDTO) {
        return shopBaseService.checkTheStatus(userTokenBeanDTO);
    }
    /**
     * 查询店铺的发票状态  feign
     */
    @PostMapping("/queryShopInvoiceSwitch")
    public InvoiceSwitchEntityVO queryShopInvoiceSwitch(@RequestBody Map<String, Object> paramTmp) {
        return shopBaseService.queryShopInvoiceSwitch(paramTmp);
    }
    /**
     * 根据shopid 查询店铺信息 feign
     */
    @PostMapping("/queryShopInfo")
    public GdsShopDetailResultVO queryShopinfoByShopId(@RequestParam("shopId") Integer shopId) {
        return shopBaseService.queryShopinfoByShopId(shopId);
    }

    /**
     * 查询首页信息
     *
     * @param shopId
     * @return
     */
    @GetMapping("/shopIndex")
    public ResponseResult selectByShopIndex(@RequestParam("shopId") Integer shopId) {
        ResponseResult result = shopBaseService.selectByShopId(shopId);
        return result;
    }

    /**
     * 店铺收藏量更新 feign
     *
     * @param paraMap
     * @return
     */
    @PostMapping("/update/shop/collect")
    public ResponseResult updateShopCollect(@RequestBody Map<String, String> paraMap) {

        return shopBaseService.updateShopCollect(paraMap);
    }

    /**
     * 校验店铺名称
     * @param shopName
     * @return
     */
    @GetMapping("/check/shopName")
    public ResponseResult checkShopNameExist(@RequestParam("shopName") String shopName) {
        return shopBaseService.checkShopNameExist(shopName);
    }

    /**
     * 删除店铺经营类目
     *
     * @param shopClassBindQueryDTO
     * @return
     */
    @PostMapping("/class/bind/delete")
    public ResponseResult deleteShopClassBind(@RequestBody ShopClassBindQueryDTO shopClassBindQueryDTO) {
        return shopBaseService.deleteShopClassBind(shopClassBindQueryDTO);
    }

    /**
     * 删除店铺经营类目
     *
     * @param param
     * @return
     */
    @PostMapping("/class/bind/deleteBatch")
    public ResponseResult deleteShopClassBindBatch(@RequestBody ShopClassBindBatchDeleteDTO param) {
        return shopBaseService.deleteShopClassBindBatch(param);
    }

    /**
     * 更新店铺经营类目
     *
     * @param param
     * @return
     */
    @PostMapping("/class/bind/updateBatch")
    public ResponseResult updateShopClassBindBatch(@RequestBody GdbMerchantClassBindDTO param) {

        return shopBaseService.updateShopClassBindBatch(param);
    }
    /**
     * 获取卖家id卖家名
     *
     * @return
     */
    @GetMapping("/selectUserIdByShopId")
    public ShopUserMessageResultVO queryUserId(@RequestParam("shopId") Integer shopId){
        return shopBaseService.queryUserId(shopId);
    }
    /**
     * 查询店铺首页
     *
     * @param param
     * @return
     */
    @PostMapping("/query/index")
    public ResponseResult queryShopIndex(@RequestBody WebShopGoodsListQueryDTO param) {

        return shopBaseService.queryShopIndex(param);
    }

    /**
     * 查询特色店铺的信息
     */
    @PostMapping("/platform/findQueryByShopId")
    public ResponseResult findQueryByShopId(@RequestBody Map<String, String> map) {
        return  shopBaseService.queryByShopIdFind(map);
    }

    /**
     * 查询是否存在店铺
     *
     * @param map
     * @return
     */
    @PostMapping("/shopName/queryShop")
    public ResponseResult queryShopStatus(@RequestBody Map<String, String> map) {
        ShopBaseEntity shopBaseEntity = shopBaseService.queryShopStatus(map);
        return ResponseResult.success(shopBaseEntity);
    }

    /**
     * 查看-店铺收费标准
     *
     * @param param
     * @return
     */
    @PostMapping("/query/expense")
    public ResponseResult queryShopJoinExpense(@RequestBody Map<String,Object> param) {
        return shopClassService.queryShopJoinExpense(param);
    }

    /**
     * 店铺分类查询列表
     *
     * @param param
     * @return
     */
    @PostMapping("/classList")
    public ResponseResult queryShopClassList(@RequestBody ShopClassQueryDTO param) {

        return shopClassService.queryShopClassList(param);
    }

    /**
     * 查看运营信息
     *
     * @param param
     * @return
     */
    @PostMapping("/operate/message/query")
    public ResponseResult queryOperateMessage(@RequestBody PersonMessageQueryDTO param) {

        return shopBaseService.queryOperateMessage(param);
    }

    /**
     * 查询商家发票功能是否开启
     *
     * @param param Map<Object,Object>
     * @return ResultResp
     */
    @PostMapping("/query/shop/invoiceSwitchStatus")
    public ResponseResult queryShopInvoiceSwitchStatus(@RequestBody Map<String,Object> param) {
        return shopBaseService.queryShopInvoiceSwitchStatus(param);
    }
    /**
     * 判断个人店铺、企业店铺
     */
    @PostMapping("/qualifications/query")
    public ResponseResult queryQualifications(@RequestBody UserTokenBeanDTO userTokenBeanDTO) {

        return shopBaseService.queryQualifications(Integer.valueOf(userTokenBeanDTO.getShopId()));
    }

    /**
     * 查询是否是自己的商品或者经销商品
     */
    @PostMapping("/check/isSelfGoods")
    public ResponseResult checkIsSelfGoods(@RequestBody Map<String,Object> param) {
        return shopBaseService.checkIsSelfGoods(param);
    }

    /**
     * 判断用户是否入驻和个人或企业入驻
     *
     * @param param
     * @return
     */
    @PostMapping("/shop/status/query")
    public ResponseResult queryShopStatus(@RequestBody UserTokenBeanDTO param) {
        return shopBaseService.queryShopTypeStatus(param);
    }

    /**
     * 店铺免额度查询
     * @param param
     * @return
     */
    @PostMapping("/free/shipping/query")
    public ResponseResult queryFreeShipping(@RequestBody UserTokenBeanDTO param) {
        return shopBaseService.queryFreeShipping(param);
    }


    /**
     * 根据shopId查询shopName  feign
     * @param shopId
     * @return
     */
    @PostMapping("/select/shopName")
    public String selectShopNameByShopId(@RequestParam("shopId") Integer shopId) {
        return shopBaseService.selectShopNameByShopId(shopId);
    }




    /**
     * 新增自营店铺
     *
     * @param param
     * @return
     */
    @PostMapping("/addSelfShop")
    public ResponseResult selfshopadd(@RequestBody Map<String,Object> param) throws IOException {
        ResponseResult result = shopBaseService.selfshopadd(param);

        return result;
    }

    /**
     * 新增供应商自营店铺
     *
     * @param param
     * @return
     */
    @PostMapping("/addSupplierSelfShop")
    public ResponseResult supplierselfshopadd(@RequestBody Map<String,Object> param) throws IOException {
        ResponseResult result = shopBaseService.supplierselfshopadd(param);

        return result;
    }



    /**
     * 删除自营店铺
     * @param paraMap
     * @return
     * @throws IOException
     */
    @PostMapping("/deleteSelfShop")
    public ResponseResult deleteselfshop(@RequestBody Map<String, Object> paraMap) throws IOException {
        ResponseResult signUtil = shopBaseService.deleteselfshop(paraMap);
        return signUtil;
    }


    /**
     * 库存预警短信提醒
     * @param param
     * @return
     * @throws ParseException
     */
    @PostMapping("/sentInventoryWarningPort")
    public ResponseResult sentInventoryWarningPort(@RequestBody Map<String, String> param) throws ParseException {
        ResponseResult result=shopBaseService.sentInventoryWarningPort(param);

        return result;
    }

    /**
     * 查询店铺数量
     *
     * @param map
     * @return
     */
    @PostMapping("/queryShopCount")
    public ResponseResult shopCount(@RequestBody Map<String, Object> map) {
        return shopBaseService.shopCount(map);
    }

    /**
     * 更新店铺免额度
     *
     * @param param
     * @return
     */
    @PostMapping("/free/shipping/update")
    public ResponseResult updateFreeShipping(@RequestBody ManageShopFreeShippingDTO param) {
        return shopBaseService.updateFreeShipping(param);
    }

    /**
     * 查询每日店铺数量
     *
     * @param map
     * @return
     */
    @RequestMapping("/shopTodayNumber")
    public ResponseResult shopTodayNumber(@RequestBody Map<String, Object> map) {
        return shopBaseService.shopTodayNumber(map);
    }

    /**
     *获取店铺列表
     * @param map
     * @return
     */
    @PostMapping("/all/shop")
    public ResponseResult queryAllshop(@RequestBody Map<String, Object> map) {
        ResponseResult result=shopBaseService.queryAllshop(map);
        return result;
    }

    /**
     * 查询自营店铺详情
     *
     * @param shopId
     * @return
     */
    @GetMapping("/query/self/shop/detail")
    public ResponseResult querySelfShopDetail(@RequestParam("shopId") Integer shopId,@RequestParam("token")String token) {
        ResponseResult result=shopBaseService.querySelfShopDetail(shopId);
        return result;
    }

    /**
     * 更新自营店铺
     *
     * @param dto
     * @return
     */
    @PostMapping("/self/shop/update")
    public ResponseResult updateSelfShop(@RequestBody SelfShopUpdateDTO dto) {
        ResponseResult result=shopBaseService.updateSelfShop(dto);
        return result;
    }

    /**
     * 查询自营店铺列表
     *
     * @param dto
     * @return
     */
    @PostMapping("/query/self/shop/list")
    public ResponseResult querySelfShopList(@RequestBody ShopBaseListQueryDTO dto) throws IllegalAccessException {
        ResponseResult result=shopBaseService.querySelfShopList(dto);
        return result;
    }

    /**
     * 店铺设置查询
     *
     * @param param
     * @return
     */
    @PostMapping("/setShop/query")
    public ResponseResult querySetShop(@RequestBody UserTokenBeanDTO param) {
        return shopBaseService.querySetShop(param);
    }

    /**
     * 店铺设置更新
     *
     * @param param
     * @return
     */
    @PostMapping("/setShop/add")
    public ResponseResult addSetShop(@RequestBody ManageSetShopParamAddDTO param) {
        return shopBaseService.updateSetShop(param);
    }

    /**
     * 店铺轮播增加
     *
     * @param param
     * @return
     */
    @PostMapping("/slide/add")
    public ResponseResult addShopSlide(@RequestBody ManageShopSlideDTO param) {
        return shopBaseService.addShopSlide(param);
    }

    /**
     * 店铺轮播查询
     *
     * @param param
     * @return
     */
    @PostMapping("/slide/query")
    public ResponseResult queryShopSlide(@RequestBody ManageShopSlideDTO param) {
        return shopBaseService.queryShopSlide(param);
    }

    /**
     * 查询质保金信息
     *
     * @param param
     * @return
     */
    @PostMapping("/deposit/query")
    public ResponseResult queryDeposit(@RequestBody DepositDetailDTO param) {
        return shopBaseService.queryDeposit(param);
    }

    /**
     * 更新质保金
     *
     * @param param
     * @return
     */
    @PostMapping("/deposit/update")
    public ResponseResult updateDeposit(@RequestBody DepositDetailDTO param) {
        return shopBaseService.updateDeposit(param);
    }

    /**
     * 查询退保信息
     *
     * @param param
     * @return
     */
    @PostMapping("/returnBond/query")
    public ResponseResult queryReturnBond(@RequestBody DepositDetailDTO param) {
        return shopBaseService.queryReturnBond(param);
    }

    /**
     * 更新退保信息
     *
     * @param param
     * @return
     */
    @PostMapping("/returnBond/update")
    public ResponseResult updateReturnBond(@RequestBody ReturnBondDTO param) {
        return shopBaseService.updateReturnBond(param);
    }

    /**
     * 商家申请打开/关闭开票功能
     *
     * @param param Map<Object,Object>
     * @return ResultResp
     */
    @PostMapping("/invoiceSwitch/update")
    public ResponseResult updateInvoiceSwitch(@RequestBody Map<String,Object> param) {
        return shopBaseService.updateInvoiceSwitch(param);
    }

    /**
     * 查询商家开票功能状态
     *
     * @param param Map<Object,Object>
     * @return ResultResp
     */
    @PostMapping("/invoiceSwitch/query")
    public ResponseResult queryInvoiceSwitch(@RequestBody Map<String,Object> param) {
        return shopBaseService.queryInvoiceSwitch(param);
    }


    /**
     * 平台-查看店铺资质详情
     *
     * @param param
     * @return
     */
    @PostMapping("/platform/aptitudeDetail")
    public ResponseResult queryShopJoinAptitudeDetailForPlatform(@RequestBody Map<String, Object> param) {
        ResponseResult result=shopBaseService.queryShopJoinAptitudeDetailForPlatform(param);
        return result;
    }

    /**
     * 验证
     *
     * @param param
     * @return
     */
    @PostMapping("/modifyVerify")
    public ResponseResult verifyShopMesModify(@RequestBody ShopBusinessModifyVerifyDTO param) {
        ResponseResult result=shopBaseService.verifyShopMesModify(param);
        return result;
    }

    /**
     * 平台-查看店铺资质列表
     *
     * @param param
     * @return
     */
    @PostMapping("/platform/aptitudeList")
    public ResponseResult queryShopJoinAptitudeListForPlatform(@RequestBody Map<String, Object> param) {
        ResponseResult result=shopBaseService.queryShopJoinAptitudeListForPlatform(param);
        return result;
    }

    /**
     * 店铺名更改审核
     *
     * @param param
     * @return
     */
    @PostMapping("/verifyShopName")
    public ResponseResult verifyShopNameModify(@RequestBody ShopNameModifyVerifyDTO param) {
        ResponseResult result = shopBaseService.verifyShopNameModify(param);
        return result;
    }


    /**
     * 查询店铺名更改列表
     *
     * @param param
     * @return
     */
    @PostMapping("/modifyShopName/list")
    public ResponseResult queryShopNameModifyList(@RequestBody ShopBaseListDTO param) {
        ResponseResult result = shopBaseService.queryShopNameModifyList(param);
        return result;
    }

    /**
     * 导出店铺设置列表
     *
     * @param param
     * @return
     */
    @PostMapping("/query/shopListExp")
    public ResponseResult queryShopListExp(@RequestBody ShopBaseListDTO param) {
        ResponseResult result = shopBaseService.queryShopListExp(param);
        return result;
    }


    /**
     * 查询店铺设置列表
     *
     * @param param
     * @return
     */
    @PostMapping("/query/shopList")
    public ResponseResult queryShopList(@RequestBody ShopBaseListDTO param) {
        ResponseResult result = shopBaseService.queryShopList(param);
        return result;
    }

    /**
     * 编辑店铺信息
     *
     * @param param
     * @return
     */
    @PostMapping("/base/update")
    public ResponseResult updateShopBase(@RequestBody ShopBaseUpdateDTO param) {
        ResponseResult result = shopBaseService.updateShopBase(param);
        return result;
    }

    /**
     * 查询编辑店铺的详情
     *
     * @param param
     * @return
     */
    @PostMapping("/base/query")
    public ResponseResult queryUpdateShopBase(@RequestBody Map<String,Object>  param) {
        ResponseResult result = shopBaseService.queryUpdateShopBase(param);
        return result;
    }


    /**
     * 平台审核商家开票功能
     *
     * @param param Map<Object,Object>
     * @return ResultResp
     */
    @PostMapping("/invoice/switch/audit")
    public ResponseResult auditShopInvoiceSwitch(@RequestBody Map<String, Object> param) {
        ResponseResult result = shopBaseService.auditShopInvoiceSwitch(param);
        return result;
    }

    /**
     * 平台查询商家开票功能状态
     *
     * @param param Map<Object,Object>
     * @return ResultResp
     */
    @PostMapping("/query/invoice/switch")
    public ResponseResult queryShopInvoiceSwitchs(@RequestBody ShopBaseListDTO param) {
        return shopBaseService.queryShopInvoiceSwitchs(param);
    }

    /**
     * 移动端 查询所有店铺
     */
    @PostMapping("/uniapp/queryShopList")
    public ResponseResult uniappQueryShopList(@RequestBody ShopListQueryDTO param) {

        return shopBaseService.uniappQueryShopList(param);
    }

    /**
     * 店铺按月分组统计
     *
     */
    @RequestMapping("/shopGroupingStatistics")
    public ResponseResult shopGroupingStatistics(@RequestBody Map<String, Object> map) {
        ResponseResult result = shopBaseService.shopGroupingStatistics(map);
        return result;
    }

    /**
     * 店铺装修设置
     *
     * @param param
     * @return
     */
    @PostMapping("/decoration/update")
    public ResponseResult addShopDecoration(@RequestBody ShopDecorationAddDTO param) {
        ResponseResult result = shopBaseService.addShopDecoration(param);
        return result;
    }


    /**
     * 店铺装修设置
     *
     * @param param
     * @return
     */
    @PostMapping("/decoration/query")
    public ResponseResult queryShopDecoration(@RequestBody UserTokenBeanDTO param) {
        ResponseResult result = shopBaseService.queryShopDecoration(param);
        return result;
    }


    /**
     * 校验店铺是否为聚宝店铺
     * @param param
     * @return
     */
    @PostMapping("/check/shopTreasure")
    public ResponseResult checkShopIsTreasure(@RequestBody UserTokenBeanDTO param) {
        ResponseResult result = shopBaseService.checkShopIsTreasure(param);
        return result;
    }

    /**
     * 店铺参与聚宝活动详情查询
     *
     * @param param
     * @return
     */
    @PostMapping("/shop/grade/query")
    public ResponseResult queryShopTreasureGrade(@RequestBody UserTokenBeanDTO param) {
        ResponseResult result = shopBaseService.queryShopTreasureGrade(param);
        return result;
    }

    /**
     * 店铺参与聚宝活动信息更新
     *
     * @param param
     * @return
     */
    @PostMapping("/shop/grade/update")
    public ResponseResult updateShopTreasureGrade(@RequestBody ShopTreasureGradeUpdateDTO param) {

        ResponseResult result = shopBaseService.updateShopTreasureGrade(param);
        return result;
    }


    /**
     * 店铺视频查询
     *
     * @param param
     * @return
     */
    @PostMapping("/video/query")
    public ResponseResult queryVideo(@RequestBody ManageShopVideoParamDTO param) {
        return shopBaseService.queryVideo(param);
    }


    /**
     *店铺列表
     * @param param
     * @return
     */
    @PostMapping("/list/filter")
    public ResponseResult queryShopListFilter(@RequestBody WebShopListQueryDTO param) throws IllegalAccessException {
        ResponseResult result = shopBaseService.queryShopListFilter(param);
        return result;
    }
    /**
     * 查询所有非供应商店铺
     *
     * @param param
     * @return
     */
    @PostMapping("/query/allRegularStore")
    public ResponseResult allRegularStore(@RequestBody ShopBaseListQueryDTO param) {
        ResponseResult  result = shopBaseService.allRegularStore(param);
        return result;
    }


    /**
     * 查询质保金信息
     */
    @PostMapping("/selectRetention")
    public ResponseResult selectretention(@RequestBody Map<String,Object> map){
        ResponseResult  result = shopBaseService.selectretention(map);
        return result;
    }


    /**
     * 查询店铺质保金列表
     */
    @PostMapping("/queryShop")
    public ResponseResult queryshop(@RequestBody Map<String,Object> map){
        ResponseResult result = shopBaseService.queryshop(map);
        return result;
    }


    /**
     * 查询店铺质保金列表导出
     */
    @PostMapping("/queryShopExp")
    public ResponseResult queryshopExp(@RequestBody Map<String,Object> map){
        ResponseResult result = shopBaseService.queryshopExp(map);
        return result;
    }
}
